using System.Data.Entity.Migrations;
using IdentityModels;
using Microsoft.AspNet.Identity;

namespace IdentityData.Migrations
{
    public sealed class Configuration : DbMigrationsConfiguration<IdentityDataDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
            AutomaticMigrationDataLossAllowed = true;
            ContextKey = "IdentityData.IdentityDataDbContext";
        }

        protected override void Seed(IdentityDataDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
//            context.Users.AddOrUpdate(
//                p => p.UserName,
//                new AppUser {UserName = "Ivo", PasswordHash = "Ivo"},
//                new AppUser {UserName = "Kukata", PasswordHash = "Kukata"},
//                new AppUser {UserName = "Martin", PasswordHash = "Martin"}
//                );
            //

          //  context.Users.AddOrUpdate();

            var userManager = new UserManager<AppUser>(new CustomeUserStore(context));
            userManager.CreateAsync(new AppUser {UserName = "Ivo", PasswordHash = "Ivo"});
            userManager.CreateAsync(new AppUser {UserName = "Kukata", PasswordHash = "Kukata"});
            userManager.CreateAsync(new AppUser { UserName = "Martin", PasswordHash = "Martin" });


        }
    }
}